package com.endava.Generics;

import java.util.ArrayList;
import java.util.List;

/**
 * Exercise 1 second version with strategy
 * 
 * @author adumitrescu
 * 
 */
/*
 * 1. Write a generic method to count the number of elements in a collection
 * that have a specific property (for example, odd integers, prime numbers,
 * palindromes).
 */
public class Ex1V2 {

	public static void main(String[] args) {

		List<Integer> list = new ArrayList<Integer>();
		list.add(0);
		list.add(1);
		list.add(2);
		list.add(3);
		list.add(4);
		list.add(5);
		list.add(6);
		list.add(7);
		list.add(8);
		list.add(9);

		NumberOperation<Integer> numberOp = new IntegerOperation();
		int count = Util.<Integer> countOddNumbers(list, numberOp);
		System.out.println(count);

		int count2 = Util.<Integer> countPrimeNumbers(list, numberOp);
		System.out.println(count2);

	}
}
